package com.xiyuan.Entity2Json;

import com.xiyuan.Entity2Json.bean.JsonResult;

public class Entity2JsonContext {
    private AbstractEntity2JsonStrategy strategy;

    public Entity2JsonContext() {
        this.strategy = new DefaultEntity2JsonStrategy();
    }

    public Entity2JsonContext(AbstractEntity2JsonStrategy strategy) {
        this.strategy = strategy;
    }

    public JsonResult execute(Class<?> clazz) throws IllegalAccessException {
        JsonResult result = this.strategy.toJsonString(clazz);
        System.out.println(result.getJsonString().toString());
        return result;
    }
}
